home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / util / ttime / part01 / ttime.c < prev    next >
C/C++ Source or Header  |  1990-08-13  |  3KB  |  66 lines

  1. /******************************************************************************
  2. *  This program will tell you how long it will take to send a file to a remote*
  3. *     computer.  All you do is give it the name of the file and the baud rate *
  4. *     that you will be sending the file at.                                   *
  5. ******************************************************************************/
  6. /******************************************************************************
  7. *         ____                                                                *
  8. *        / / /  Amiga 1000  | Thomas "Maverick" Schwarz  -  Sirius Software   *
  9. *       / / /  The  Machine |     Box 349 Caromar Dr.  Mars, PA  16046        *
  10. *____  / / /   That Made It |                (412) 443-8916                   *
  11. *\ \ \/ / /      Possible!  |                                                 *
  12. * \ \/ / /          --      |UUCP: {allegra,cadre}!pitt!darth!floopy!maverick *
  13. *  \/_/_/         First!    |  or: ...uunet!nfsun!eklektik!thomas             *
  14. ******************************************************************************/
  15.  
  16. /**** COPYRIGHT 1990 Thomas "Maverick" Schwarz - Sirius Software ****/
  17.  
  18. #include <libraries/dos.h>
  19. #include <intuition/intuition.h>
  20. #include <exec/memory.h>
  21. #include <stdio.h>
  22.  
  23. struct FileLock *mylock  = NULL;
  24. struct FileInfoBlock *fib = NULL;
  25.  
  26. main(argc,argv)
  27. int argc;
  28. char *argv[];
  29. {
  30. int success, baud;
  31. long tsecs, hours, mins, secs;
  32.  
  33.     if (argv[1] == "?")
  34.         {
  35.         printf("\nUsage: TTime <filename> <baud rate>\n\n");
  36.         exit(0);
  37.         }
  38.     if (argc < 2)
  39.         {
  40.         printf("\nUsage: TTime <filename> <baud rate>\n\n");
  41.         exit(0);
  42.         }
  43.     baud = atoi(argv[2]);
  44.     if (baud == 0)
  45.         {
  46.         printf("\nUseage: TTime <filename> <baud rate>\n\n");
  47.         exit(0);
  48.         }
  49.     if((fib = (struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock),MEMF_PUBLIC|MEMF_CLEAR))==NULL)
  50.         exit(0);
  51.     mylock = (struct FileLock *)Lock(argv[1],ACCESS_READ);
  52.     if(!(success = Examine(mylock,fib)))
  53.         {
  54.             printf("\n\n\nFile Not Locked!\n\n");
  55.             FreeMem(fib,sizeof(struct FileInfoBlock));
  56.             exit(0);
  57.         }
  58.     tsecs = ((((fib->fib_Size) *10) / baud) + (fib->fib_Size / 1920)); 
  59.     hours = (tsecs / 3600);
  60.     mins = ((tsecs - 60 * hours) / 60);
  61.     secs = (tsecs - (mins * 60) - (hours * 3600));
  62.     printf("\nTransfer time will be: %02d:%02d:%02d\n\n",hours,mins,secs);
  63.     FreeMem(fib,sizeof(struct FileInfoBlock));
  64.     UnLock(mylock);
  65. }
  66.